<template>
    <view class="content">
        <view class="top">
            <image :src="IMAGEURL + 'static/icon/icon_05.png'" class="icon-05"></image>
            <view>拒绝延期订单</view>
        </view>
        <view class="box">
            <view class="title">请选择拒绝延期原因，便于更好得服务</view>
            <view class="item" v-for="(item, index) in list" :key="index" @click="choose(item)">
                <view class="u-flex-1">{{item.name}}</view>
                <image v-if="item.checked" :src="IMAGEURL + 'static/icon/choose_01.png'" class="choose-01"></image>
                <image v-if="!item.checked" :src="IMAGEURL + 'static/icon/choose_02.png'" class="choose-01"></image>
            </view>
        </view>
        <view class="btn" @click="submit">提交</view>
    </view>
</template>

<script>
    import { IMAGEURL } from '@/static/js/common.js';
    export default {
        data() {
            return {
                IMAGEURL,
                id: '',
                list: {},
            };
        },
        onLoad(option) {
            this.id = option.id
            this.getOption()
        },
        methods: {
            submit() {
                var cid = ''
                this.list.forEach(ii => {
                    if (ii.checked) {
                        cid = ii.id
                    }
                })
                if (!cid) {
                    this.$toast('请选择拒绝延期原因')
                    return
                }
                
                this.$ajax('confirm_order_delay', {
                	user_token: this.$getSync('userToken'),
                	delay_id: this.id,//延期id
                    refuse_id: cid,//拒绝原因id
                    status: 5,//3同意 5拒绝
                }).then(ret => {
                	if (ret.success == 1000) {
                		this.$toast('提交成功')
                        setTimeout(() => {
                            this.$backT()
                        }, 500)
                	} else {
                		this.$toast(ret.msg);
                	}
                });
            },
            
            choose(item) {
                const nowStatu = item.checked;
                this.list.forEach(ii => {
                    ii.checked = false;
                })
                item.checked =! nowStatu
            },
            
            getOption() {
            	this.$ajax('order_option', {
            		
            	}).then(ret => {
            		if (ret.success == 1000) {
            			this.list = ret.detail.refuse
                        this.list.forEach(cur => {
                            this.$set(cur, 'checked', false)
                        })
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f5f6f8;
    }
    .content{
        padding: 20rpx;
    }
    .top{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 10rpx 0 45rpx;
        font-size: 40rpx;
        font-weight: bold;
    }
    .icon-05{
        width: 60rpx;
        height: 60rpx;
        margin-bottom: 15rpx;
    }
    
    .box{
        background-color: #fff;
        border-radius: 10rpx;
        padding: 0 20rpx;
    }
    .title{
        font-size: 30rpx;
        font-weight: bold;
        padding: 30rpx 0;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 0;
        font-size: 28rpx;
        border-top: 2rpx solid #eee;
    }
    .choose-01{
        width: 33rpx;
        height: 33rpx;
        margin-left: 15rpx;
    }
    .btn{
        font-size: 34rpx;
        color: #fff;
        text-align: center;
        padding: 25rpx;
        background-color: #f29700;
        border-radius: 20rpx;
        margin-top: 50rpx;
    }

</style>
